//这里封装了常用的需要写入模板引擎的东西
var User = require('../database/redis/userDao');

let asyncWriteHeader = async function (req, res) {
    if (req.session.userId != null) {
        let userData = await User.asyncGetDataById(req.session.userId);
        //如果找不到会返回null
        if (userData != null) {
            //用户信息写入模板引擎
            res.locals.userData = userData;
        }
    }
}

module.exports = {
    asyncWriteHeader
}